#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=400010;
pair<ll,ll>p[N];
set<ll>s;
ll solve(){
	int n=s.size(),cnt=1,nn=n;
	ll sum=0,now,las,ans=0;
	for(auto i=s.begin();i!=s.end();i++,cnt++){
		p[cnt].first=sum;
		sum+=*i;
	}
	cnt=1;
	sum=0;
	for(auto i=s.rbegin();i!=s.rend();i++,cnt++){
		p[cnt].second=sum-1;
		if(p[cnt].first>p[cnt].second){
			p[cnt].first=1e18;
			nn--;
		}
		sum+=*i;
	}
	sort(p+1,p+n+1);
	now=0;
	las=1;
	n=nn;
	for(int i=1;i<=n;i++){
		if(p[i].first>now){
			ans+=now-las+1;
			las=p[i].first;
			now=p[i].second;
		}
		else{
			now=max(now,(ll)p[i].second);
		}
	}
	return ans+now-las+1;
}
int main(){
	freopen("kte.in","r",stdin);
	freopen("kte.out","w",stdout);
	int t;
	ll x;
	scanf("%d",&t);
	while(t--){
		scanf("%lld",&x);
		if(s.find(x)!=s.end()){
			s.erase(x);
		}
		else{
			s.insert(x);
		}
		printf("%lld\n",solve());
	}
}